feat: migrate bb-prover from direct binary execution to bb.js API#21564
feat: migrate bb-prover from direct binary execution to bb.js API#21564charlielye wants to merge 1 commit intonextfrom
Conversation
|
Hey Charlie, this looks nice, just one comment for the AVM. We regularly use the following flow for all kinds of debugging, testing, benchmarking and iterating: we run some test (e.g., the avm bulk test). This test writes the avm inputs file and outputs the exact bb-avm command that you'd need to run. After that, we can just use that command (and that file) and operate 100% on the CLI/C++ side. We can then easily change the passed environment variables, concurrency, etc. IIUC, these changes would break that because the files wouldn't be written? |
This should now be covered by setting a |
25f6490 to
613e654
Compare
613e654 to
970f34c
Compare
Summary
Migrates all
bb-proverserver-side proving and verification from spawningbb/bb-avmbinaries viachild_process.spawn()to using the bb.js TypeScript API (Barretenbergclass viaNativeUnixSocketbackend). This eliminates temporary file I/O (writing/reading bytecode, witnesses, proofs, VKs to disk) and stdout-based result parsing. A fresh bb process is still spawned per proof to maintain parallelism, but communication happens via Unix socket instead of files.What was migrated
bb provevia spawnapi.circuitProve()via bb.jsbb verifyvia spawnapi.circuitVerify()via bb.jsbb verify --scheme chonkvia spawn + temp filesapi.chonkVerify()via bb.jsbb-avm avm_provevia spawn + temp filesapi.avmProve()via bb.jsbb-avm avm_verifyvia spawn + temp filesapi.avmVerify()via bb.jsbb-avm avm_check_circuitvia spawn + temp filesapi.avmCheckCircuit()via bb.jsbb gatesvia spawnapi.circuitStats()/api.chonkStats()via bb.jsbb contractvia spawnapi.circuitWriteSolidityVerifier()via bb.jsKey changes
BBJsInstance/BBJsProverFactory(bb_js_backend.ts): Adapter layer wrapping theBarretenbergclass with typed methods for all proof operationsDebugBBJsInstance(bb_js_debug.ts): Debug wrapper that writes inputs/outputs to disk and logs equivalent CLI commands (see debug section below)bbapi_avm.hpp/cpp): Three new bbapi command structs (AvmProve,AvmVerify,AvmCheckCircuit) with in-memory function implementations invm2/api_avm.cppand stub implementations invm2_stub/api_avm.cppsplitChonkProofToStructured): Converts flatFr[]proof arrays to structuredChonkProofformat expected bychonkVerify, using sub-proof sizes inlined from C++static_assertvaluesexecute.ts(6 dead functions)Debug workflow with
BB_DEBUG_OUTPUT_DIRSet the
BB_DEBUG_OUTPUT_DIRenvironment variable to enable file-based debugging. When set,DebugBBJsInstancewraps all bb.js calls and:command.shscript with the equivalentbbCLI command that can be re-run manuallyExample:
Each subdirectory contains the input files and a
command.shthat reproduces the operation using thebbCLI binary, useful for isolating failures outside of the TypeScript stack.Test plan
🤖 Generated with Claude Code